package com.ruoyi.traffic.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.traffic.domain.TrafficHardwareInfo;
import com.ruoyi.traffic.service.ITrafficHardwareInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 硬件设备信息Controller
 * 
 * @author lzh
 * @date 2025-03-16
 */
@RestController
@RequestMapping("/traffic/info")
public class TrafficHardwareInfoController extends BaseController
{
    @Autowired
    private ITrafficHardwareInfoService trafficHardwareInfoService;

    /**
     * 查询硬件设备信息列表
     */
    @PreAuthorize("@ss.hasPermi('traffic:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(TrafficHardwareInfo trafficHardwareInfo)
    {
        startPage();
        List<TrafficHardwareInfo> list = trafficHardwareInfoService.selectTrafficHardwareInfoList(trafficHardwareInfo);
        return getDataTable(list);
    }

    /**
     * 导出硬件设备信息列表
     */
    @PreAuthorize("@ss.hasPermi('traffic:info:export')")
    @Log(title = "硬件设备信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TrafficHardwareInfo trafficHardwareInfo)
    {
        List<TrafficHardwareInfo> list = trafficHardwareInfoService.selectTrafficHardwareInfoList(trafficHardwareInfo);
        ExcelUtil<TrafficHardwareInfo> util = new ExcelUtil<TrafficHardwareInfo>(TrafficHardwareInfo.class);
        util.exportExcel(response, list, "硬件设备信息数据");
    }

    /**
     * 获取硬件设备信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('traffic:info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(trafficHardwareInfoService.selectTrafficHardwareInfoById(id));
    }

    /**
     * 新增硬件设备信息
     */
    @PreAuthorize("@ss.hasPermi('traffic:info:add')")
    @Log(title = "硬件设备信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TrafficHardwareInfo trafficHardwareInfo)
    {
        return toAjax(trafficHardwareInfoService.insertTrafficHardwareInfo(trafficHardwareInfo));
    }

    /**
     * 修改硬件设备信息
     */
    @PreAuthorize("@ss.hasPermi('traffic:info:edit')")
    @Log(title = "硬件设备信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TrafficHardwareInfo trafficHardwareInfo)
    {
        return toAjax(trafficHardwareInfoService.updateTrafficHardwareInfo(trafficHardwareInfo));
    }

    /**
     * 删除硬件设备信息
     */
    @PreAuthorize("@ss.hasPermi('traffic:info:remove')")
    @Log(title = "硬件设备信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(trafficHardwareInfoService.deleteTrafficHardwareInfoByIds(ids));
    }
}
